<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>76_构造函数</title>
		<script>
			class Person {
				name = "孙悟空"
				age = 10;
				gender = "男";
				sayHello() {
					console.log(this.name + this.age);
				}
			}

			const p1 = new Person();
			const p2 = new Person();
			console.log(p1);
			console.log(p2);
			class Dog {
				name
				age
				gender
				// 在类中可以添加一个特殊的方法constructor
				// 该方法我们称为构造函数(构造方法)
				// 构造函数会在我们调用类创建对象时执行
				constructor(name, age, gender) {
					console.log(name, age, gender);
					this.name = name;
					this.age = age;
					this.gender = gender;
				}
			}

			const d1 = new Dog("大黄", 11, "男");
			const d2 = new Dog("大黄2", 111, "男");
			
		</script>
	</head>
	<body>
	</body>
</html>